/**
 * @ClassDescription:
 * @JdkVersion: 1.8
 * @Author: 李白
 * @Created: 2024/4/22 10:28
 */
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

public class OutputWriter {
    // 将分析结果写入文件和屏幕
    public static void writeOutput(List<String> outputLines, String filename) {
        try {
            BufferedWriter writer = new BufferedWriter(new FileWriter(filename));
            for (String line : outputLines) {
                writer.write(line);
                writer.newLine();
            }
            writer.close();
            // 在屏幕上打印结果
            for (String line : outputLines) {
                System.out.println(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
